package com.jdrx.sw.sewage.api.web;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.jdrx.platform.commons.rest.beans.dto.IdDTO;
import com.jdrx.platform.commons.rest.beans.vo.ResponseVO;
import com.jdrx.platform.commons.rest.factory.ResponseFactory2;
import com.jdrx.sw.sewage.beans.dto.WaterQualityTestTemplateAddDTO;
import com.jdrx.sw.sewage.beans.entity.WaterQualityTestTemplatePO;
import com.jdrx.sw.sewage.service.WaterQualityTestTemplateService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

@RestController
@RequestMapping(value = "/api/waterQualityTestTemplate")
@Api(value = "水质化验报表模板")
public class WaterQualityTestTemplateApi {
	@Autowired
	private WaterQualityTestTemplateService waterQualityTestTemplateService;
	
	@ApiOperation(value = "新增水质化验报表模板")
    @PostMapping(value = "add")
    public ResponseVO<?> add(@RequestBody @Validated WaterQualityTestTemplateAddDTO dto) {
		waterQualityTestTemplateService.add(dto);
        return ResponseFactory2.ok();
    }
	
	@ApiOperation(value = "删除水质化验报表模板")
    @PostMapping(value = "delete")
    public ResponseVO<?> delete(@RequestBody @Validated IdDTO<Long> dto) {
		waterQualityTestTemplateService.delete(dto.getId());
        return ResponseFactory2.ok();
    }
	
	@ApiOperation(value = "水质化验报表模板列表")
    @PostMapping(value = "list")
    public ResponseVO<List<WaterQualityTestTemplatePO>> list() {
        return ResponseFactory2.ok(waterQualityTestTemplateService.list());
    }
}